package edu.thu.thss.yxy.sip;

/**
 * The CallState class reflects the current state of a call. 
 *
 * @author Andy Gao
 */
public class CallState
{
    public static final String _CALL_INITIALIZATION = "Initializing";
    public static final CallState CALL_INITIALIZATION =
        new CallState(_CALL_INITIALIZATION);
    public static final String _DIALING         = "拨号";
    public static final CallState DIALING = new CallState(_DIALING);
    public static final String _RINGING         = "等待应答";
    public static final CallState RINGING = new CallState(_RINGING);
    public static final String _ALERTING        = "来电";
    public static final CallState ALERTING = new CallState(_ALERTING);
    public static final String _CONNECTED       = "已连接";
    public static final CallState CONNECTED = new CallState(_CONNECTED);
    public static final String _DISCONNECTED    = "断开";
    public static final CallState DISCONNECTED = new CallState(_DISCONNECTED);
    public static final String _BUSY            = "占线";
    public static final CallState BUSY = new CallState(_BUSY);
    public static final String _FAILED          = "失败";
    public static final CallState FAILED = new CallState(_FAILED);
    
    /**
     * A string representation of this Call State. Could be
     * _CALL_INITIALIZATION, _CALL_IN_PROGRESS, _CALL_ENDED.
     */
    private String callStateStr;

    /**
     * Create a call state object with a value corresponding to the specified
     * string.
     *
     * @param callState a string representation of the state.
     */
    private CallState(String callState)
    {
        this.callStateStr = callState;
    }

    /**
     * Returns a String representation of this CallState.
     *
     * @return a string value (one of the _CALL_XXX constants) representing this
     *         call state).
     */
    public String getStateString()
    {
        return callStateStr;
    }

    /**
     * Returns a string representation of this call state. Strings returned by
     * this method have the following format: "CallState:<STATE_STRING>" and are
     * meant to be used for logging/debugging purposes.
     *
     * @return a string representation of this object.
     */
    public String toString()
    {
        return getStateString();
    }
}
